/*
 * process.h
 *
 *  Created on: 2011/04/23
 *      Author: AKS
 */

#ifndef PROCESS_H_
#define PROCESS_H_

#include "types.h"
#include "list.h"

// process initialize function(class..)
typedef BOOL (*PROCESS_INIT_FUNC)(BYTE);

// process base function(class..)
typedef void (*PROCESS_BASE_FUNC)(void *);

// process wake-up condition
typedef BOOL (*WAKE_UP_CONDITION)(void *);

// process core
typedef struct _PROCESS
{
	// process core function
	PROCESS_BASE_FUNC function;
	void *param;

	// wake up condition
	WAKE_UP_CONDITION wakeUp;
	void *wakeUpParam;

	// process system
	WORD id;
} PROCESS;


// process lists
extern LIST_ITEM *waitingProcess;
extern LIST_ITEM *execReadyProcess;
extern LIST_ITEM *executingProcess;

// cyclic process
extern LIST_ITEM *cycleProcess;

extern LIST_ITEM initialProcessItm;


// functions for process control system
void initProcessController(void);
BOOL sleepCurrentProcess(WAKE_UP_CONDITION wakeCondition, void *wakeUpParamater);
BOOL entryNewProcess(LIST_ITEM *process);
BOOL wakeUpNextProcess(void);
WORD checkWakeUp(void);

#endif /* PROCESS_H_ */
